package com.xiyu.service.controller.admin.unit;
import com.xiyu.service.vo.unit.rank.RankSimpleListOutput;
import com.xiyu.service.vo.unit.rank.RankSingleGetOutput;
import com.xiyu.service.vo.unit.rank.RankUpdateInput;
import com.xiyu.service.vo.unit.rank.RankCreateInput;
import com.xiyu.service.vo.unit.rank.RankPageQueryOutput;
import com.xiyu.service.vo.unit.rank.RankPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.unit.RankService;

@Tag(name = "职级管理")
@RestController
@RequestMapping("/unit/rank")
@Validated
public class RankController {

    @Resource
    private RankService rankService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询职级")
    @PreAuthorize("@ss.hasPermission('unit:rank:query')")
    public CommonResult<PageResult<RankPageQueryOutput>> pageQuery(@Valid RankPageQueryInput inputVO) {
        return success(rankService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增职级")
    @PreAuthorize("@ss.hasPermission('unit:rank:create')")
    public CommonResult<Long> create(@Valid @RequestBody RankCreateInput inputVO) {
        return success(rankService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新职级")
    @PreAuthorize("@ss.hasPermission('unit:rank:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody RankUpdateInput inputVO) {
        return success(rankService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个职级")
    @Parameter(name = "id", description = "职级主键ID", example = "")
    public CommonResult<RankSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(rankService.singleGet(id));
    }

    @GetMapping("/simple-list")
    @Operation(summary = "查询职级")
    public CommonResult<List<RankSimpleListOutput>> simpleList() {
        return success(rankService.simpleList());
    }

}
